import request from './request'

export const getUserInfo = (params: { id: number }) => 
  request.get('/user/info', { params })

export const login = (data: { username: string; password: string }) =>
  request.post('/auth/login', data)

export const updateUser = (data: { id: number; name: string }) =>
  request.put('/user/update', data)

// 新增首页内容接口
export const getHomeContent = () =>  
  request.get('/api/home')

// 新增标签筛选接口
export const getSelectTag = () =>  
  request.get('/api/selecttag')

// 新增菜单接口
export const getMenus = () =>  
  request.get('/api/menu')

// 新增分类接口
export const getCategories = (id: string | number) =>  
  request.get(`/api/category/${id}`)

// 新增面包屑导航接口
export const getBreadcrumb = (id: string | number) =>  
  request.get(`/api/breadcrumb/${id}`)

// 新增文章相关接口
export const getArticle = (id: string | number) =>  
  request.get(`/api/article/${id}`)

export const addComment = (id: string | number, data: { content: string }) =>  
  request.post(`/api/article/${id}/comments`, data)

export const likeArticle = (id: string | number) =>  
  request.post(`/api/article/${id}/like`)

export const favoriteArticle = (id: string | number) =>  
  request.post(`/api/article/${id}/favorite`)